<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Blog extends CI_Controller {
		public $catalogs;
		public function __construct(){
		parent::__construct();
		$this->load->helper('url');	
		$this->load->model('Catalog_model');
		$this->load->model('Article_model');
		$this->catalogs=$this->Catalog_model->get_all();
	}
		public function index(){
		// $this->load->library('pagination');
		// $total=$this->Article_model->count_all();
		// $config['base_url'] = "site_url('Blog/index')";
		// $config['total_rows'] = $total;
		// $config['per_page'] = 5;
		// $this->pagination->initialize($config);
		$articles=$this->Article_model->get_all();
		$data=array(
			'catalogs'=>$this->catalogs,
			'articles'=>$articles,
			'catalog_id'=>0
			);
		$this->load->view('Blog_index',$data);
	}
	public function view($id){
		$article=$this->Article_model->get_one($id);
		$this->Article_model->view_once($id);
		$data=array(
			'catalogs'=>$this->catalogs,
			'article'=>$article,
			'catalog_id'=>$article->catalog_id
			);
		$this->load->view('article_view',$data);
	}
	public function lists($catalog_id){
		$articles=$this->Article_model->get_list_catalog_id($catalog_id);
		$data=array(
			'catalogs'=>$this->catalogs,
			'articles'=>$articles,
			'catalog_id'=>$catalog_id
			);
		$this->load->view('Blog_index',$data);
	}

}
